# ---------------------------------------------------------------------
# Reproducible environment for “Survey Professionalism
# ---------------------------------------------------------------------

FROM rocker/r-ver:4.4.2

# ── 1. Install system libraries needed by R packages ─────────────────
RUN apt-get update -qq && \
    DEBIAN_FRONTEND=noninteractive \
    apt-get install -y --no-install-recommends \
        build-essential      \ 
        cmake                \  
        libcurl4-openssl-dev \
        libssl-dev           \
        libxml2-dev          \
        libharfbuzz-dev \  
        libfribidi-dev \ 
	      libfreetype6-dev \
	      libfontconfig1-dev  \
        libgit2-dev \
        libjpeg-dev \  
        libtiff5-dev \
        pandoc \
        libpng-dev && \
    apt-get clean && rm -rf /var/lib/apt/lists/*

# ── 2. Copy the project into the image ───────────────────────────────
ENV RENV_PATHS_LIBRARY=/opt/renv/library
WORKDIR /survey_professionals
COPY . /survey_professionals

# ── 3. Install renv and restore the exact R library ──────────────────
RUN R -e "install.packages('renv', repos = 'https://cloud.r-project.org'); \
          renv::consent(TRUE); \
          renv::restore()"

# ── 4. Default command: run the full analysis ────────────────────────
CMD ["Rscript", "run.R"]

